home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 983 b | 43 lines | [TEXT/MPS ] |
- { VBL nonsense for Q&A’s }
-
- UNIT PersistentVBL;
-
- INTERFACE
-
- USES Types,Memory,OSUtils,Retrace;
-
- FUNCTION InstallPersistentVBL(VAR theVBLRec: VBLTask): OSErr;
-
- IMPLEMENTATION
-
- CONST
- JMPInstr = $4EF9; { This is an absolute JMP }
- JMPSize = 6; { Size of an absolute JMP }
-
- FUNCTION InstallPersistentVBL(VAR theVBLRec: VBLTask): OSErr;
-
- TYPE
- ProcPtrPtr = ^ProcPtr;
-
- VAR
- theErr: OSErr;
- SysHeapPtr: Ptr;
- tempPtr: Ptr;
-
- BEGIN
- SysHeapPtr := NewPtrSys(6);
- theErr := MemError;
- IF theErr <> noErr THEN { We are in a WORLD of hurt! }
- BEGIN
- InstallPersistentVBL := theErr;
- EXIT(InstallPersistentVBL);
- END;
- INTEGERPtr(SysHeapPtr)^ := JMPInstr; { Shove in the JMP }
- tempPtr := Ptr(ORD(SysHeapPtr)+2); { Expletive deleted }
- ProcPtrPtr(tempPtr)^ := theVBLRec.vblAddr; { We want to JMP to the original VBL task }
- theVBLREc.vblAddr := ProcPtr(SysHeapPtr); { Point record at SysHeap }
- InstallPersistentVBL := VInstall(@theVBLRec); { Install that thang! }
- END;
-
- END.
-